package isquirrel;

import isquirrel.semantic.DBpedia;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class DBpediaWorker implements Runnable {

	
	private DBpedia dbPedia = null;
	private DBpediaCollection dbPediaCollection = null;
	private List<String> subjects = null;
	
	public DBpediaWorker(List<String> subjects, DBpediaCollection dbPediaCollection, DBpedia dbPedia) {		
		this.subjects = subjects;
		this.dbPediaCollection = dbPediaCollection;
		this.dbPedia = dbPedia;
	}
	
	public void run() {
		add(dbPedia.getUrlsFromSubjects(new HashSet<String>(subjects)));
		dbPediaCollection.decrementWorkers();
	}

	public synchronized void add(Set<String> subjects) {
		this.dbPediaCollection.add(subjects);
	}
	
		
}


